import 'package:flutter/material.dart';

///Title:水波纹点击 <br/>
///Description: <br/>
///author:xiemiao <br/>
///date: 2020-02-28 <br/>
///version 1.0 <br/>
class WaterClick extends StatelessWidget {
  final VoidCallback onPressed;
  final VoidCallback onLongPress;
  final ValueChanged<bool> onHighlightChanged;
  final TextStyle textStyle;
  final Color fillColor;
  final Color focusColor;
  final Color hoverColor;
  final Color highlightColor;
  final Color splashColor;
  final double elevation;
  final double hoverElevation;
  final double focusElevation;
  final double highlightElevation;
  final double disabledElevation;
  final EdgeInsetsGeometry padding;
  final BoxConstraints constraints;
  final ShapeBorder shape;
  final Duration animationDuration;
  final Widget child;
  final MaterialTapTargetSize materialTapTargetSize;
  final FocusNode focusNode;
  final bool autofocus;
  final Clip clipBehavior;
  final bool enableFeedback;

  final AlignmentGeometry alignment;
  final EdgeInsetsGeometry margin;
  final Decoration decoration;
  final double width;
  final double height;
  final double minWidth;
  final double minHeight;
  final bool enable;

  const WaterClick({
    Key key,
    @required this.onPressed,
    this.width,
    this.height,
    this.minWidth = 0.0,
    this.minHeight = 0.0,
    this.enable = true,
    this.alignment,
    this.decoration,
    this.margin,
    this.onLongPress,
    this.onHighlightChanged,
    this.textStyle,
    this.fillColor,
    this.focusColor,
    this.hoverColor,
    this.highlightColor,
    this.splashColor,
    this.elevation = 0.0,
    this.focusElevation = 4.0,
    this.hoverElevation = 4.0,
    this.highlightElevation = 8.0,
    this.disabledElevation = 0.0,
    this.padding = EdgeInsets.zero,
    this.constraints = const BoxConstraints(minWidth: 0.0, minHeight: 0.0),
    this.shape = const RoundedRectangleBorder(),
    this.animationDuration = kThemeChangeDuration,
    this.clipBehavior = Clip.none,
    this.focusNode,
    this.autofocus = false,
    MaterialTapTargetSize materialTapTargetSize,
    this.child,
    this.enableFeedback = true,
  })  : materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.shrinkWrap,
        assert(shape != null),
        assert(elevation != null && elevation >= 0.0),
        assert(focusElevation != null && focusElevation >= 0.0),
        assert(hoverElevation != null && hoverElevation >= 0.0),
        assert(highlightElevation != null && highlightElevation >= 0.0),
        assert(disabledElevation != null && disabledElevation >= 0.0),
        assert(padding != null),
        assert(constraints != null),
        assert(animationDuration != null),
        assert(clipBehavior != null),
        assert(autofocus != null),
        super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: width,
      height: height,
      constraints: BoxConstraints(minWidth: minWidth, minHeight: minHeight),
      margin: margin,
      decoration: decoration,
      child: RawMaterialButton(
        key: key,
        onPressed: enable ? onPressed : null,
        onLongPress: enable ? onLongPress : null,
        onHighlightChanged: onHighlightChanged,
        textStyle: textStyle,
        fillColor: fillColor,
        focusColor: focusColor,
        hoverColor: hoverColor,
        highlightColor: highlightColor,
        splashColor: splashColor,
        elevation: elevation,
        focusElevation: focusElevation,
        hoverElevation: hoverElevation,
        highlightElevation: highlightElevation,
        disabledElevation: disabledElevation,
        padding: padding,
        constraints: constraints,
        shape: shape,
        animationDuration: animationDuration,
        clipBehavior: clipBehavior,
        focusNode: focusNode,
        autofocus: autofocus,
        materialTapTargetSize: materialTapTargetSize,
        enableFeedback: enableFeedback,
        child: Container(
          alignment: alignment,
          child: child,
        ),
      ),
    );
  }
}
